import axios from "axios";

// 1、获取列表数据
export function getListAPI(params) {
  return axios({
    url: "http://localhost:3001/data",
    method: "GET",
    params,
  });
}

// 2、新增列表数据
export function addListAPI(data) {
  return axios({
    url: "http://localhost:3001/data",
    method: "POST",
    data,
  });
}

// 3、删除列表数据
export function delListAPI(id) {
  return axios({
    url: `http://localhost:3001/data/${id}`,
    method: "DELETE",
  });
}

// 4、搜索接口
export function searchListAPI(name) {
  return axios({
    url: "http://localhost:3001/data/",
    method: "GET",
    params: {
      name,
    },
  });
}

// 5、编辑接口
export function editListAPI(data) {
  return axios({
    url: `http://localhost:3001/data/${data.id}`,
    method: "PUT",
    data,
  });
}

// 6、详情接口
export function getDetailAPI(id) {
  return axios({
    url: `http://localhost:3001/data/${id}`,
    method: "GET",
  });
}
